const { ref } = Vue;
import { useFetch } from '../../Scripts/hooks/useFetch.js'

export function useGetUserInfo() {
  const userInfo = ref({
    employeeid: '',
    employeename: '',
    fullname: '',
    factoryname: '',
    factoryid: '',
    factorycode: '',
    workcentername: '',
    workcenterid: '',
    shiftname: '',
    shiftid: '',
    teamname: '',
    teamid: '',
    rolenames: ''
  });

  // 查询用户信息
  const getUserInfo = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        type: `${configObj.method}`,
        employeeid: `${configObj.employeeid}`
      }
    });
    if (data.value.length > 0) {
      userInfo.value = data.value[0];
    }
  }

  return { userInfo, getUserInfo }
}